<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>初始化页面</title>
</head>
<script src="../script/vue.js"></script>
<body>
    <h2>人员列表（遍历数组）</h2>
    
    <div id="person">
        <button @click.once="addPerson">添加人员</button>
        <ul>
            <li v-for="person in personList" :key="person.idCardNumber">
                {{person.name}}-{{person.name}}-{{person.idCardNumber}}
            </li>
        </ul>
    </div>  
</body>

<script>
    new Vue({
        el:"#person",
        data: {
            personList: [
                {'name':'张三','age':18,'idCardNumber':'360122199590945252'},
                {'name':'李四','age':19,'idCardNumber':'360122199590942462'},
                {'name':'王五','age':20,'idCardNumber':'360122199590945246'}
            ]
        },
        methods: {
            addPerson: function () {
                this.personList.push({'name':'赵六','age':21,'idCardNumber':'360122199590945246'})
            }
        }
    })
</script>

</html>
